home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / librw / RWpistream.z / RWpistream
Encoding:
Text File  |  1998-10-30  |  21.0 KB  |  463 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWpistream - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include <rw/pstream.h>
  13.  
  14.  
  15.  
  16.               RWpistream pstr(cin); // Construct an RWpistream, using cin's
  17.                                 // streambuf
  18.  
  19.  
  20.  
  21.  
  22. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  23.      Class RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm specializes the abstract base class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm to
  24.      restore variables stored in a portable ASCII format by RRRRWWWWppppoooossssttttrrrreeeeaaaammmm.  You
  25.      can think of RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm and RRRRWWWWppppoooossssttttrrrreeeeaaaammmm as an ASCII veneer over an
  26.      associated ssssttttrrrreeeeaaaammmmbbbbuuuuffff which are responsible for formatting variables and
  27.      escaping characters such that the results can be interchanged between any
  28.      machines.  As such, they are slower than their binary counterparts
  29.      RRRRWWWWbbbbiiiissssttttrrrreeeeaaaammmm and RRRRWWWWbbbboooossssttttrrrreeeeaaaammmm which are more machine dependent.  Because
  30.      RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm and RRRRWWWWppppoooossssttttrrrreeeeaaaammmm retain no information about the state of their
  31.      associated ssssttttrrrreeeeaaaammmmbbbbuuuuffffs, their use can be freely exchanged with other users
  32.      of the ssssttttrrrreeeeaaaammmmbbbbuuuuffff (such as iiiissssttttrrrreeeeaaaammmm or iiiiffffssssttttrrrreeeeaaaammmm).  RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm can be
  33.      interrogated as to the stream state using member functions ggggoooooooodddd(((()))), bbbbaaaadddd(((()))),
  34.      eeeeooooffff(((()))), eeeettttcccc.
  35.  
  36. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  37.      None
  38.  
  39. EEEExxxxaaaammmmpppplllleeee
  40.      See RRRRWWWWppppoooossssttttrrrreeeeaaaammmm for an example of how to create an input stream for this
  41.      program.
  42.  
  43.               #include <rw/pstream.h>
  44.           main(){
  45.              // Construct an RWpistream to use standard input
  46.              RWpistream pstr(cin);
  47.              int i;
  48.              float f;
  49.              double d;
  50.              char string[80];
  51.              pstr >> i;  // Restore an int that was stored in binary
  52.              pstr >> f >> d;  // Restore a float & double
  53.              pstr.getString(string, 80);  // Restore a character string
  54.           }
  55.  
  56. PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
  57.               RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm(streambuf* s);
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.      Initialize an RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm from the streambuf ssss.
  75.  
  76.               RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm(istream& str);
  77.  
  78.  
  79.      Initialize an RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm using the ssssttttrrrreeeeaaaammmmbbbbuuuuffff associated with the iiiissssttttrrrreeeeaaaammmm
  80.      ssssttttrrrr.
  81.  
  82. PPPPuuuubbbblllliiiicccc OOOOppppeeeerrrraaaattttoooorrrrssss
  83.               virtual RWvistream&
  84.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(char& c);
  85.  
  86.  
  87.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next character from the input
  88.      stream and store it in cccc.  This member attempts to preserve the symbolic
  89.      characters values transmitted over the stream.
  90.  
  91.               virtual RWvistream&
  92.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(wchar_t& wc);
  93.  
  94.  
  95.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next wwwwiiiiddddeeee cccchhhhaaaarrrr from the input
  96.      stream and store it in wwwwcccc.
  97.  
  98.               virtual RWvistream&
  99.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(double& d);
  100.  
  101.  
  102.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next ddddoooouuuubbbblllleeee from the input
  103.      stream and store it in dddd.
  104.  
  105.               virtual RWvistream&
  106.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(float& f);
  107.  
  108.  
  109.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next ffffllllooooaaaatttt from the input
  110.      stream and store it in ffff.
  111.  
  112.               virtual RWvistream&
  113.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(int& i);
  114.  
  115.  
  116.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next iiiinnnntttt from the input stream
  117.      and store it in iiii.
  118.  
  119.               virtual RWvistream&
  120.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(long& l);
  121.  
  122.  
  123.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next lllloooonnnngggg from the input stream
  124.      and store it in llll.
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.               virtual RWvistream&
  141.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(short& s);
  142.  
  143.  
  144.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next sssshhhhoooorrrrtttt from the input
  145.      stream and store it in ssss.
  146.  
  147.               virtual RWvistream&
  148.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(unsigned char& c);
  149.  
  150.  
  151.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next uuuunnnnssssiiiiggggnnnneeeedddd cccchhhhaaaarrrr from the
  152.      input stream and store it in cccc.
  153.  
  154.               virtual RWvistream&
  155.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(unsigned short& s);
  156.  
  157.  
  158.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next uuuunnnnssssiiiiggggnnnneeeedddd sssshhhhoooorrrrtttt from the
  159.      input stream and store it in ssss.
  160.  
  161.               virtual RWvistream&
  162.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(unsigned int& i);
  163.  
  164.  
  165.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next uuuunnnnssssiiiiggggnnnneeeedddd iiiinnnntttt from the
  166.      input stream and store it in iiii.
  167.  
  168.               virtual RWvistream&
  169.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(unsigned long& l);
  170.  
  171.  
  172.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next uuuunnnnssssiiiiggggnnnneeeedddd lllloooonnnngggg from the
  173.      input stream and store it in llll.
  174.  
  175.               ooooppppeeeerrrraaaattttoooorrrr vvvvooooiiiidddd****();
  176.  
  177.  
  178.      Inherited via RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm from RRRRWWWWvvvviiiioooossss.
  179.  
  180. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  181.               virtual int
  182.           ggggeeeetttt();
  183.  
  184.  
  185.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get and return the next character from
  186.      the input stream.  Returns EEEEOOOOFFFF if end of file is encountered.
  187.  
  188.               virtual RWvistream&
  189.           ggggeeeetttt(char& c);
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  203.  
  204.  
  205.  
  206.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next char and store it in cccc.
  207.      This member only preserves ASCII numerical codes, not the coresponding
  208.      character symbol.
  209.  
  210.               virtual RWvistream&
  211.           ggggeeeetttt(wchar_t& wc);
  212.  
  213.  
  214.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next wwwwiiiiddddeeee cccchhhhaaaarrrr and store it in
  215.      wwwwcccc.
  216.  
  217.               virtual RWvistream&
  218.           ggggeeeetttt(unsigned char& c);
  219.  
  220.  
  221.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get the next uuuunnnnssssiiiiggggnnnneeeedddd cccchhhhaaaarrrr and store it
  222.      in cccc.
  223.  
  224.               virtual RWvistream&
  225.           ggggeeeetttt(char* v, size_t N);
  226.  
  227.  
  228.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get a vector of cccchhhhaaaarrrrs and store them in
  229.      the array beginning at vvvv. If the restore operation stops prematurely,
  230.      because there are no more data available on the stream, because an
  231.      exception is thrown, or for some other reason; ggggeeeetttt stores what has
  232.      already been retrieved from the stream into vvvv, and sets the failbit.
  233.      Note that this member preserves ASCII numerical codes, not their
  234.      corresponding character values.  If you wish to restore a character
  235.      string, use the function ggggeeeettttSSSSttttrrrriiiinnnngggg((((cccchhhhaaaarrrr****,,,, ssssiiiizzzzeeee____tttt))))....
  236.  
  237.               virtual RWvistream&
  238.           ggggeeeetttt(wchar_t* v, size_t N);
  239.  
  240.  
  241.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get a vector of wide cccchhhhaaaarrrrs and store
  242.      them in the array beginning at vvvv. If the restore operation stops
  243.      prematurely, because there are no more data available on the stream,
  244.      because an exception is thrown, or for some other reason; ggggeeeetttt stores what
  245.      has already been retrieved from the stream into vvvv, and sets the failbit.
  246.      Note that this member preserves ASCII numerical codes, not their
  247.      corresponding character values.  If you wish to restore a character
  248.      string, use the function ggggeeeettttSSSSttttrrrriiiinnnngggg((((cccchhhhaaaarrrr****,,,, ssssiiiizzzzeeee____tttt))))....
  249.  
  250.               virtual RWvistream&
  251.           ggggeeeetttt(double* v, size_t N);
  252.  
  253.  
  254.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get a vector of ddddoooouuuubbbblllleeees and store them
  255.      in the array beginning at vvvv. If the restore operation stops prematurely,
  256.      because there are no more data available on the stream, because an
  257.      exception is thrown, or for some other reason; ggggeeeetttt stores what has
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  269.  
  270.  
  271.  
  272.      already been retrieved from the stream into vvvv, and sets the failbit.
  273.  
  274.               virtual RWvistream&
  275.           ggggeeeetttt(float* v, size_t N);
  276.  
  277.  
  278.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get a vector of ffffllllooooaaaatttts and store them
  279.      in the array beginning at vvvv. If the restore operation stops prematurely,
  280.      because there are no more data available on the stream, because an
  281.      exception is thrown, or for some other reason; ggggeeeetttt stores what has
  282.      already been retrieved from the stream into vvvv, and sets the failbit.
  283.  
  284.               virtual RWvistream&
  285.           ggggeeeetttt(int* v, size_t N);
  286.  
  287.  
  288.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get a vector of iiiinnnntttts and store them in
  289.      the array beginning at vvvv. If the restore operation stops prematurely,
  290.      because there are no more data available on the stream, because an
  291.      exception is thrown, or for some other reason; ggggeeeetttt stores what has
  292.      already been retrieved from the stream into vvvv, and sets the failbit.
  293.  
  294.               virtual RWvistream&
  295.           ggggeeeetttt(long* v, size_t N);
  296.  
  297.  
  298.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get a vector of lllloooonnnnggggs and store them in
  299.      the array beginning at vvvv. If the restore operation stops prematurely,
  300.      because there are no more data available on the stream, because an
  301.      exception is thrown, or for some other reason; ggggeeeetttt stores what has
  302.      already been retrieved from the stream into vvvv, and sets the failbit.
  303.  
  304.               virtual RWvistream&
  305.           ggggeeeetttt(short* v, size_t N);
  306.  
  307.  
  308.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get a vector of sssshhhhoooorrrrtttts and store them
  309.      in the array beginning at vvvv. If the restore operation stops prematurely,
  310.      because there are no more data available on the stream, because an
  311.      exception is thrown, or for some other reason; ggggeeeetttt stores what has
  312.      already been retrieved from the stream into vvvv, and sets the failbit.
  313.  
  314.               virtual RWvistream&
  315.           ggggeeeetttt(unsigned char* v, size_t N);
  316.  
  317.  
  318.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get a vector of uuuunnnnssssiiiiggggnnnneeeedddd cccchhhhaaaarrrrs and
  319.      store them in the array beginning at vvvv. If the restore operation stops
  320.      prematurely, because there are no more data available on the stream,
  321.      because an exception is thrown, or for some other reason; ggggeeeetttt stores what
  322.      has already been retrieved from the stream into vvvv, and sets the failbit.
  323.      Note that this member preserves ASCII numerical codes, not their
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  335.  
  336.  
  337.  
  338.      corresponding character values.  If you wish to restore a character
  339.      string, use the function ggggeeeettttSSSSttttrrrriiiinnnngggg((((cccchhhhaaaarrrr****,,,, ssssiiiizzzzeeee____tttt))))....
  340.  
  341.               virtual RWvistream&
  342.           ggggeeeetttt(unsigned short* v, size_t N);
  343.  
  344.  
  345.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get a vector of uuuunnnnssssiiiiggggnnnneeeedddd sssshhhhoooorrrrtttts and
  346.      store them in the array beginning at vvvv. If the restore operation stops
  347.      prematurely, because there are no more data available on the stream,
  348.      because an exception is thrown, or for some other reason; ggggeeeetttt stores what
  349.      has already been retrieved from the stream into vvvv, and sets the failbit.
  350.  
  351.               virtual RWvistream&
  352.           ggggeeeetttt(unsigned int* v, size_t N);
  353.  
  354.  
  355.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get a vector of uuuunnnnssssiiiiggggnnnneeeedddd iiiinnnntttts and store
  356.      them in the array beginning at vvvv. If the restore operation stops
  357.      prematurely, because there are no more data available on the stream,
  358.      because an exception is thrown, or for some other reason; ggggeeeetttt stores what
  359.      has already been retrieved from the stream into vvvv, and sets the failbit.
  360.  
  361.               virtual RWvistream&
  362.           ggggeeeetttt(unsigned long* v, size_t N);
  363.  
  364.  
  365.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Get a vector of uuuunnnnssssiiiiggggnnnneeeedddd lllloooonnnnggggs and
  366.      store them in the array beginning at vvvv. If the restore operation stops
  367.      prematurely, because there are no more data available on the stream,
  368.      because an exception is thrown, or for some other reason; ggggeeeetttt stores what
  369.      has already been retrieved from the stream into vvvv, and sets the failbit.
  370.  
  371.               virtual RWvistream&
  372.           ggggeeeettttSSSSttttrrrriiiinnnngggg(char* s, size_t N);
  373.  
  374.  
  375.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Restores a character string from the
  376.      input stream and stores it in the array beginning at ssss. The function
  377.      stops reading at the end of the string or after NNNN----1111 characters, whichever
  378.      comes first.  If NNNN----1111 characters have been read and the NNNNtttthhhh character is
  379.      not the string terminator, then the failbit of the stream will be set.
  380.      In either case, the string will be terminated with a null byte.  If the
  381.      input stream has been corrupted, then an exception of type RRRRWWWWEEEExxxxtttteeeerrrrnnnnaaaallllEEEErrrrrrrr
  382.      will be thrown.
  383.  
  384.               virtual RWvistream&
  385.           ggggeeeettttSSSSttttrrrriiiinnnngggg(wchar_t* ws, size_t N);
  386.  
  387.  
  388.      Redefined from class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Restores a character string from the
  389.      input stream and stores it in the array beginning at wwwwssss.  The function
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  401.  
  402.  
  403.  
  404.      stops reading at the end of the string or after NNNN----1111 characters, whichever
  405.      comes first. If NNNN----1111 characters have been read and the NNNNtttthhhh character is
  406.      not the string terminator, then the failbit of the stream will be set.
  407.      In either case, the string will be terminated with a null byte.  If the
  408.      input stream has been corrupted, then an exception of type RRRRWWWWEEEExxxxtttteeeerrrrnnnnaaaallllEEEErrrrrrrr
  409.      will be thrown.
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.                                                                         PPPPaaaaggggeeee 7777
  460.  
  461.  
  462.  
  463.